//
//  TOHeaderView.m
//  B段项目
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "TOHeaderView.h"



@implementation TOHeaderView

-(instancetype)init
{
    self = [super init];
    if (self) {
        [self createSubview];
    }
    
    return self;
}

-(void)createSubview
{
    //用户头像
    self.headImageView = [[UIImageView alloc] init];
    self.headImageView.image = [UIImage imageNamed:@"iconfont-touxiang.png"];
    [self addSubview:self.headImageView];
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(WIDTH*0.05);
        make.top.mas_equalTo(WIDTH*0.1);
        make.width.height.mas_equalTo(self.mas_height).multipliedBy(0.35);
    }];

    //用户名
    self.userName = [[UILabel alloc] init];
    self.userName.text = @"登录";
    self.userName.textColor = [UIColor colorWithHue:0 saturation:0 brightness:0.56 alpha:1];
    [self addSubview:self.userName];
    
    [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.headImageView.mas_right).offset(10);
        make.top.mas_equalTo(self.headImageView.mas_top);
        make.width.mas_equalTo(self.mas_width).multipliedBy(0.5);
        make.height.mas_equalTo(self.headImageView.mas_height);
    }];
    

    
    
    
    //搜索 按钮
    self.search = [[UIButton alloc] init];
    self.search.backgroundColor = [UIColor colorWithRed:0.41 green:0.41 blue:0.41 alpha:1];
   
    [self addSubview:self.search];
    [self.search mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.headImageView.bottom).offset(WIDTH*0.4);
        make.left.mas_equalTo(self.headImageView).offset(15);
        make.width.mas_equalTo(self.mas_width).multipliedBy(0.5);
        make.height.mas_equalTo(self.mas_height).multipliedBy(0.1);
        
    }];
    NSLog(@"%f", self.search.frame.size.height);
    self.search.layer.cornerRadius = HEIGHT*0.3*0.1*0.5;
    self.search.layer.masksToBounds = NO;
    
 
    UIImageView *img = [[UIImageView alloc] init];
    img.image = [UIImage imageNamed:@"iconfont-sousuo-2.png"];
    [self.search addSubview:img];
    
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.search).offset(3);
        make.left.mas_equalTo(self.search).offset(8);
        make.height.width.mas_equalTo(self.search.mas_height).multipliedBy(0.6);
    }];
    

}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/



@end
